/**
 * 
 */

function navigate(pageName) {
	if (pageName != null) {
		var target = window.location + 'pages/' + pageName + '.html';
		window.location.assign(target);
	}
}

function clickTextField(textField, defaultVal){
	var val = textField.value;
	if(val === defaultVal){
		textField.value = '';
	}
}

function blurTextField(textField, defaultVal){
	var val = textField.value;
	if(val === ''){
		textField.value = defaultVal;
	}
}

function clickPasswordField(passwordField, defaultVal){
	var val = passwordField.value;
	if(val === defaultVal || val=== ''){
		passwordField.setAttribute('type', 'password');
		passwordField.setAttribute('value', '');
	}
}
function blurPasswordField(passwordField){
	var id = passwordField.id;
	var defaultVal = '';
	if(id === 'password'){
		defaultVal = 'enter password';
	}else if(id === 'confirm'){
		defaultVal = 'confirm password';
	}
	var val = passwordField.value;
	
	if(val === ''){
		passwordField.setAttribute('type', 'text');
		passwordField.setAttribute('value', defaultVal);
	}
}

function loadSignUpForm() {
	//Full Name
	var fullNameTxt = document.getElementById('fullname');
	var fullNamrTxtDV = 'enter fullname';
	fullNameTxt.setAttribute('value', fullNamrTxtDV);
	fullNameTxt.onfocus = function() {
		clickTextField(fullNameTxt, fullNamrTxtDV);
	};
	fullNameTxt.onblur = function() {
		blurTextField(fullNameTxt, fullNamrTxtDV);
	};
	//Email
	var emailTxt = document.getElementById('email');
	var emailTxtDV = 'enter email';
	emailTxt.setAttribute('value', emailTxtDV);
	emailTxt.onfocus = function() {
		clickTextField(emailTxt, emailTxtDV);
	};
	emailTxt.onblur = function() {
		blurTextField(emailTxt, emailTxtDV);
	};
	//Password
	var passwordTxt = document.getElementById('password');
	var passwordTxtDV = 'enter password';
	passwordTxt.setAttribute('type','text');
	passwordTxt.setAttribute('value',passwordTxtDV);
	passwordTxt.onfocus = function() {
		clickPasswordField(this,passwordTxtDV);
	};
	passwordTxt.onblur = function() {
		blurPasswordField(this, passwordTxtDV);
	};
	//Confirm Password
	var confirmpasswordTxt = document.getElementById('confirm');
	var confirmpasswordTxtDV = 'confirm password';
	confirmpasswordTxt.setAttribute('type','text');
	confirmpasswordTxt.setAttribute('value',confirmpasswordTxtDV);
	confirmpasswordTxt.onfocus = function() {
		clickPasswordField(confirmpasswordTxt,confirmpasswordTxtDV);
	};
	confirmpasswordTxt.onblur = function() {
		blurPasswordField(confirmpasswordTxt, confirmpasswordTxtDV);
	};
}
